home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / docs / binutils / ld.i2 < prev    next >
Encoding:
GNU Info File  |  1994-12-17  |  45.9 KB  |  1,063 lines

  1. This is Info file ld.info, produced by Makeinfo-1.55 from the input
  2. file ./ld.texinfo.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Ld: (ld).                       The GNU linker.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    This file documents the GNU linker LD.
  9.  
  10.    Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided also
  18. that the entire resulting derived work is distributed under the terms
  19. of a permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions.
  24.  
  25. 
  26. File: ld.info,  Node: Section Data Expressions,  Next: Section Options,  Prev: Section Placement,  Up: SECTIONS
  27.  
  28. Section Data Expressions
  29. ------------------------
  30.  
  31.    The foregoing statements arrange, in your output file, data
  32. originating from your input files.  You can also place data directly in
  33. an output section from the link command script.  Most of these
  34. additional statements involve expressions; *note Expressions::..
  35. Although these statements are shown separately here for ease of
  36. presentation, no such segregation is needed within a section definition
  37. in the `SECTIONS' command; you can intermix them freely with any of the
  38. statements we've just described.
  39.  
  40. `CREATE_OBJECT_SYMBOLS'
  41.      Create a symbol for each input file in the current section, set to
  42.      the address of the first byte of data written from that input
  43.      file.  For instance, with `a.out' files it is conventional to have
  44.      a symbol for each input file.  You can accomplish this by defining
  45.      the output `.text' section as follows:
  46.           SECTIONS {
  47.             .text 0x2020 :
  48.                {
  49.               CREATE_OBJECT_SYMBOLS
  50.               *(.text)
  51.               _etext = ALIGN(0x2000);
  52.               }
  53.             ...
  54.           }
  55.  
  56.      If `sample.ld' is a file containing this script, and `a.o', `b.o',
  57.      `c.o', and `d.o' are four input files with contents like the
  58.      following--
  59.           /* a.c */
  60.           
  61.           afunction() { }
  62.           int adata=1;
  63.           int abss;
  64.  
  65.      `ld -M -T sample.ld a.o b.o c.o d.o' would create a map like this,
  66.      containing symbols matching the object file names:
  67.           00000000 A __DYNAMIC
  68.           00004020 B _abss
  69.           00004000 D _adata
  70.           00002020 T _afunction
  71.           00004024 B _bbss
  72.           00004008 D _bdata
  73.           00002038 T _bfunction
  74.           00004028 B _cbss
  75.           00004010 D _cdata
  76.           00002050 T _cfunction
  77.           0000402c B _dbss
  78.           00004018 D _ddata
  79.           00002068 T _dfunction
  80.           00004020 D _edata
  81.           00004030 B _end
  82.           00004000 T _etext
  83.           00002020 t a.o
  84.           00002038 t b.o
  85.           00002050 t c.o
  86.           00002068 t d.o
  87.  
  88. `SYMBOL = EXPRESSION ;'
  89. `SYMBOL F= EXPRESSION ;'
  90.      SYMBOL is any symbol name (*note Symbols::.).  "F=" refers to any
  91.      of the operators `&= += -= *= /=' which combine arithmetic and
  92.      assignment.
  93.  
  94.      When you assign a value to a symbol within a particular section
  95.      definition, the value is relative to the beginning of the section
  96.      (*note Assignment::.).  If you write
  97.  
  98.           SECTIONS {
  99.             abs = 14 ;
  100.             ...
  101.             .data : { ... rel = 14 ; ... }
  102.             abs2 = 14 + ADDR(.data);
  103.             ...
  104.           }
  105.  
  106.      `abs' and `rel' do not have the same value; `rel' has the same
  107.      value as `abs2'.
  108.  
  109. `BYTE(EXPRESSION)'
  110. `SHORT(EXPRESSION)'
  111. `LONG(EXPRESSION)'
  112. `QUAD(EXPRESSION)'
  113.      By including one of these four statements in a section definition,
  114.      you can explicitly place one, two, four, or eight bytes
  115.      (respectively) at the current address of that section.  `QUAD' is
  116.      only supported when using a 64 bit host or target.
  117.  
  118.      Multiple-byte quantities are represented in whatever byte order is
  119.      appropriate for the output file format (*note BFD::.).
  120.  
  121. `FILL(EXPRESSION)'
  122.      Specify the "fill pattern" for the current section.  Any otherwise
  123.      unspecified regions of memory within the section (for example,
  124.      regions you skip over by assigning a new value to the location
  125.      counter `.') are filled with the two least significant bytes from
  126.      the EXPRESSION argument.  A `FILL' statement covers memory
  127.      locations *after* the point it occurs in the section definition; by
  128.      including more than one `FILL' statement, you can have different
  129.      fill patterns in different parts of an output section.
  130.  
  131. 
  132. File: ld.info,  Node: Section Options,  Prev: Section Data Expressions,  Up: SECTIONS
  133.  
  134. Optional Section Attributes
  135. ---------------------------
  136.  
  137.    Here is the full syntax of a section definition, including all the
  138. optional portions:
  139.  
  140.      SECTIONS {
  141.      ...
  142.      SECNAME START BLOCK(ALIGN) (NOLOAD) : AT ( LDADR )
  143.        { CONTENTS } >REGION =FILL
  144.      ...
  145.      }
  146.  
  147.    SECNAME and CONTENTS are required.  *Note Section Definition::, and
  148. *note Section Placement::. for details on CONTENTS.  The remaining
  149. elements--START, `BLOCK(ALIGN)', `(NOLOAD)', `AT ( LDADR )', `>REGION',
  150. and `=FILL'--are all optional.
  151.  
  152. `START'
  153.      You can force the output section to be loaded at a specified
  154.      address by specifying START immediately following the section name.
  155.      sTART can be represented as any expression. The following example
  156.      generates section OUTPUT at location `0x40000000':
  157.  
  158.           SECTIONS {
  159.             ...
  160.             output 0x40000000: {
  161.               ...
  162.               }
  163.             ...
  164.           }
  165.  
  166. `BLOCK(ALIGN)'
  167.      You can include `BLOCK()' specification to advance the location
  168.      counter `.' prior to the beginning of the section, so that the
  169.      section will begin at the specified alignment.  ALIGN is an
  170.      expression.
  171.  
  172. `(NOLOAD)'
  173.      Use `(NOLOAD)' to prevent a section from being loaded into memory
  174.      each time it is accessed.  For example, in the script sample
  175.      below, the `ROM' segment is addressed at memory location `0' and
  176.      does not need to be loaded into each object file:
  177.  
  178.           SECTIONS {
  179.             ROM  0  (NOLOAD)  : { ... }
  180.             ...
  181.           }
  182.  
  183. `AT ( LDADR )'
  184.      The expression LDADR that follows the `AT' keyword specifies the
  185.      load address of the section.  The default (if you do not use the
  186.      `AT' keyword) is to make the load address the same as the
  187.      relocation address.  This feature is designed to make it easy to
  188.      build a ROM image.  For example, this `SECTIONS' definition
  189.      creates two output sections: one called `.text', which starts at
  190.      `0x1000', and one called `.mdata', which is loaded at the end of
  191.      the `.text' section even though its relocation address is
  192.      `0x2000'.  The symbol `_data' is defined with the value `0x2000':
  193.  
  194.           SECTIONS
  195.             {
  196.             .text 0x1000 : { *(.text) _etext = . ; }
  197.             .mdata 0x2000 :
  198.               AT ( ADDR(.text) + SIZEOF ( .text ) )
  199.               { _data = . ; *(.data); _edata = . ;  }
  200.             .bss 0x3000 :
  201.               { _bstart = . ;  *(.bss) *(COMMON) ; _bend = . ;}
  202.           }
  203.  
  204.      The run-time initialization code (for C programs, usually `crt0')
  205.      for use with a ROM generated this way has to include something like
  206.      the following, to copy the initialized data from the ROM image to
  207.      its runtime address:
  208.  
  209.           char *src = _etext;
  210.           char *dst = _data;
  211.           
  212.           /* ROM has data at end of text; copy it. */
  213.           while (dst < _edata) {
  214.             *dst++ = *src++;
  215.           }
  216.           
  217.           /* Zero bss */
  218.           for (dst = _bstart; dst< _bend; dst++)
  219.             *dst = 0;
  220.  
  221. `>REGION'
  222.      Assign this section to a previously defined region of memory.
  223.      *Note MEMORY::.
  224.  
  225. `=FILL'
  226.      Including `=FILL' in a section definition specifies the initial
  227.      fill value for that section.  You may use any expression to
  228.      specify FILL.  Any unallocated holes in the current output section
  229.      when written to the output file will be filled with the two least
  230.      significant bytes of the value, repeated as necessary.  You can
  231.      also change the fill value with a `FILL' statement in the CONTENTS
  232.      of a section definition.
  233.  
  234. 
  235. File: ld.info,  Node: Entry Point,  Next: Option Commands,  Prev: SECTIONS,  Up: Commands
  236.  
  237. The Entry Point
  238. ===============
  239.  
  240.    The linker command language includes a command specifically for
  241. defining the first executable instruction in an output file (its "entry
  242. point").  Its argument is a symbol name:
  243.      ENTRY(SYMBOL)
  244.  
  245.    Like symbol assignments, the `ENTRY' command may be placed either as
  246. an independent command in the command file, or among the section
  247. definitions within the `SECTIONS' command--whatever makes the most
  248. sense for your layout.
  249.  
  250.    `ENTRY' is only one of several ways of choosing the entry point.
  251. You may indicate it in any of the following ways (shown in descending
  252. order of priority: methods higher in the list override methods lower
  253. down).
  254.    * the `-e' ENTRY command-line option;
  255.  
  256.    * the `ENTRY(SYMBOL)' command in a linker control script;
  257.  
  258.    * the value of the symbol `start', if present;
  259.  
  260.    * the value of the symbol `_main', if present;
  261.  
  262.    * the address of the first byte of the `.text' section, if present;
  263.  
  264.    * The address `0'.
  265.  
  266.    For example, you can use these rules to generate an entry point with
  267. an assignment statement: if no symbol `start' is defined within your
  268. input files, you can simply define it, assigning it an appropriate
  269. value--
  270.  
  271.      start = 0x2020;
  272.  
  273. The example shows an absolute address, but you can use any expression.
  274. For example, if your input object files use some other symbol-name
  275. convention for the entry point, you can just assign the value of
  276. whatever symbol contains the start address to `start':
  277.  
  278.      start = other_symbol ;
  279.  
  280. 
  281. File: ld.info,  Node: Option Commands,  Prev: Entry Point,  Up: Commands
  282.  
  283. Option Commands
  284. ===============
  285.  
  286.    The command language includes a number of other commands that you can
  287. use for specialized purposes.  They are similar in purpose to
  288. command-line options.
  289.  
  290. `CONSTRUCTORS'
  291.      This command ties up C++ style constructor and destructor records.
  292.      The details of the constructor representation vary from one
  293.      object format to another, but usually lists of constructors and
  294.      destructors appear as special sections.  The `CONSTRUCTORS'
  295.      command specifies where the linker is to place the data from these
  296.      sections, relative to the rest of the linked output.  Constructor
  297.      data is marked by the symbol `__CTOR_LIST__' at the start, and
  298.      `__CTOR_LIST_END' at the end; destructor data is bracketed
  299.      similarly, between `__DTOR_LIST__' and `__DTOR_LIST_END'.  (The
  300.      compiler must arrange to actually run this code; GNU C++ calls
  301.      constructors from a subroutine `__main', which it inserts
  302.      automatically into the startup code for `main', and destructors
  303.      from `_exit'.)
  304.  
  305. `FLOAT'
  306. `NOFLOAT'
  307.      These keywords were used in some older linkers to request a
  308.      particular math subroutine library.  `ld' doesn't use the
  309.      keywords, assuming instead that any necessary subroutines are in
  310.      libraries specified using the general mechanisms for linking to
  311.      archives; but to permit the use of scripts that were written for
  312.      the older linkers, the keywords `FLOAT' and `NOFLOAT' are accepted
  313.      and ignored.
  314.  
  315. `FORCE_COMMON_ALLOCATION'
  316.      This command has the same effect as the `-d' command-line option:
  317.      to make `ld' assign space to common symbols even if a relocatable
  318.      output file is specified (`-r').
  319.  
  320. `INPUT ( FILE, FILE, ... )'
  321. `INPUT ( FILE FILE ... )'
  322.      Use this command to include binary input files in the link, without
  323.      including them in a particular section definition.  Specify the
  324.      full name for each FILE, including `.a' if required.
  325.  
  326.      `ld' searches for each FILE through the archive-library search
  327.      path, just as for files you specify on the command line.  See the
  328.      description of `-L' in *Note Command Line Options: Options.
  329.  
  330. `GROUP ( FILE, FILE, ... )'
  331. `GROUP ( FILE FILE ... )'
  332.      This command is like `INPUT', except that the named files should
  333.      all be archives, and they are searched repeatedly until no new
  334.      undefined references are created.  See the description of `-(' in
  335.      *Note Command Line Options: Options.
  336.  
  337. `OUTPUT ( FILENAME )'
  338.      Use this command to name the link output file FILENAME.  The
  339.      effect of `OUTPUT(FILENAME)' is identical to the effect of
  340.      `-o FILENAME', which overrides it.  You can use this command to
  341.      supply a default output-file name other than `a.out'.
  342.  
  343. `OUTPUT_ARCH ( BFDNAME )'
  344.      Specify a particular output machine architecture, with one of the
  345.      names used by the BFD back-end routines (*note BFD::.).  This
  346.      command is often unnecessary; the architecture is most often set
  347.      implicitly by either the system BFD configuration or as a side
  348.      effect of the `OUTPUT_FORMAT' command.
  349.  
  350. `OUTPUT_FORMAT ( BFDNAME )'
  351.      When `ld' is configured to support multiple object code formats,
  352.      you can use this command to specify a particular output format.
  353.      bFDNAME is one of the names used by the BFD back-end routines
  354.      (*note BFD::.).  The effect is identical to the effect of the
  355.      `-oformat' command-line option.  This selection affects only the
  356.      output file; the related command `TARGET' affects primarily input
  357.      files.
  358.  
  359. `SEARCH_DIR ( PATH )'
  360.      Add PATH to the list of paths where `ld' looks for archive
  361.      libraries.  `SEARCH_DIR(PATH)' has the same effect as `-LPATH' on
  362.      the command line.
  363.  
  364. `STARTUP ( FILENAME )'
  365.      Ensure that FILENAME is the first input file used in the link
  366.      process.
  367.  
  368. `TARGET ( FORMAT )'
  369.      When `ld' is configured to support multiple object code formats,
  370.      you can use this command to change the input-file object code
  371.      format (like the command-line option `-b' or its synonym
  372.      `-format').  The argument FORMAT is one of the strings used by BFD
  373.      to name binary formats.  If `TARGET' is specified but
  374.      `OUTPUT_FORMAT' is not, the last `TARGET' argument is also used as
  375.      the default format for the `ld' output file.  *Note BFD::.
  376.  
  377.      If you don't use the `TARGET' command, `ld' uses the value of the
  378.      environment variable `GNUTARGET', if available, to select the
  379.      output file format.  If that variable is also absent, `ld' uses
  380.      the default format configured for your machine in the BFD
  381.      libraries.
  382.  
  383. 
  384. File: ld.info,  Node: Machine Dependent,  Next: BFD,  Prev: Commands,  Up: Top
  385.  
  386. Machine Dependent Features
  387. **************************
  388.  
  389.    `ld' has additional features on some platforms; the following
  390. sections describe them.  Machines where `ld' has no additional
  391. functionality are not listed.
  392.  
  393. * Menu:
  394.  
  395. * H8/300::                      `ld' and the H8/300
  396. * i960::                        `ld' and the Intel 960 family
  397.  
  398. 
  399. File: ld.info,  Node: H8/300,  Next: i960,  Up: Machine Dependent
  400.  
  401. `ld' and the H8/300
  402. ===================
  403.  
  404.    For the H8/300, `ld' can perform these global optimizations when you
  405. specify the `-relax' command-line option.
  406.  
  407. *relaxing address modes*
  408.      `ld' finds all `jsr' and `jmp' instructions whose targets are
  409.      within eight bits, and turns them into eight-bit program-counter
  410.      relative `bsr' and `bra' instructions, respectively.
  411.  
  412. *synthesizing instructions*
  413.      `ld' finds all `mov.b' instructions which use the sixteen-bit
  414.      absolute address form, but refer to the top page of memory, and
  415.      changes them to use the eight-bit address form.  (That is: the
  416.      linker turns `mov.b `@'AA:16' into `mov.b `@'AA:8' whenever the
  417.      address AA is in the top page of memory).
  418.  
  419. 
  420. File: ld.info,  Node: i960,  Prev: H8/300,  Up: Machine Dependent
  421.  
  422. `ld' and the Intel 960 family
  423. =============================
  424.  
  425.    You can use the `-AARCHITECTURE' command line option to specify one
  426. of the two-letter names identifying members of the 960 family; the
  427. option specifies the desired output target, and warns of any
  428. incompatible instructions in the input files.  It also modifies the
  429. linker's search strategy for archive libraries, to support the use of
  430. libraries specific to each particular architecture, by including in the
  431. search loop names suffixed with the string identifying the architecture.
  432.  
  433.    For example, if your `ld' command line included `-ACA' as well as
  434. `-ltry', the linker would look (in its built-in search paths, and in
  435. any paths you specify with `-L') for a library with the names
  436.  
  437.      try
  438.      libtry.a
  439.      tryca
  440.      libtryca.a
  441.  
  442. The first two possibilities would be considered in any event; the last
  443. two are due to the use of `-ACA'.
  444.  
  445.    You can meaningfully use `-A' more than once on a command line, since
  446. the 960 architecture family allows combination of target architectures;
  447. each use will add another pair of name variants to search for when `-l'
  448. specifies a library.
  449.  
  450.    `ld' supports the `-relax' option for the i960 family.  If you
  451. specify `-relax', `ld' finds all `balx' and `calx' instructions whose
  452. targets are within 24 bits, and turns them into 24-bit program-counter
  453. relative `bal' and `cal' instructions, respectively.  `ld' also turns
  454. `cal' instructions into `bal' instructions when it determines that the
  455. target subroutine is a leaf routine (that is, the target subroutine does
  456. not itself call any subroutines).
  457.  
  458. 
  459. File: ld.info,  Node: BFD,  Next: MRI,  Prev: Machine Dependent,  Up: Top
  460.  
  461. BFD
  462. ***
  463.  
  464.    The linker accesses object and archive files using the BFD libraries.
  465. These libraries allow the linker to use the same routines to operate on
  466. object files whatever the object file format.  A different object file
  467. format can be supported simply by creating a new BFD back end and adding
  468. it to the library.  To conserve runtime memory, however, the linker and
  469. associated tools are usually configured to support only a subset of the
  470. object file formats available.  You can use `objdump -i' (*note
  471. objdump: (binutils.info)objdump.) to list all the formats available for
  472. your configuration.
  473.  
  474.    As with most implementations, BFD is a compromise between several
  475. conflicting requirements. The major factor influencing BFD design was
  476. efficiency: any time used converting between formats is time which
  477. would not have been spent had BFD not been involved. This is partly
  478. offset by abstraction payback; since BFD simplifies applications and
  479. back ends, more time and care may be spent optimizing algorithms for a
  480. greater speed.
  481.  
  482.    One minor artifact of the BFD solution which you should bear in mind
  483. is the potential for information loss.  There are two places where
  484. useful information can be lost using the BFD mechanism: during
  485. conversion and during output. *Note BFD information loss::.
  486.  
  487. * Menu:
  488.  
  489. * BFD outline::                 How it works: an outline of BFD
  490.  
  491. 
  492. File: ld.info,  Node: BFD outline,  Up: BFD
  493.  
  494. How it works: an outline of BFD
  495. ===============================
  496.  
  497.    When an object file is opened, BFD subroutines automatically
  498. determine the format of the input object file.  They then build a
  499. descriptor in memory with pointers to routines that will be used to
  500. access elements of the object file's data structures.
  501.  
  502.    As different information from the the object files is required, BFD
  503. reads from different sections of the file and processes them.  For
  504. example, a very common operation for the linker is processing symbol
  505. tables.  Each BFD back end provides a routine for converting between
  506. the object file's representation of symbols and an internal canonical
  507. format. When the linker asks for the symbol table of an object file, it
  508. calls through a memory pointer to the routine from the relevant BFD
  509. back end which reads and converts the table into a canonical form.  The
  510. linker then operates upon the canonical form. When the link is finished
  511. and the linker writes the output file's symbol table, another BFD back
  512. end routine is called to take the newly created symbol table and
  513. convert it into the chosen output format.
  514.  
  515. * Menu:
  516.  
  517. * BFD information loss::    Information Loss
  518. * Canonical format::        The BFD    canonical object-file format
  519.  
  520. 
  521. File: ld.info,  Node: BFD information loss,  Next: Canonical format,  Up: BFD outline
  522.  
  523. Information Loss
  524. ----------------
  525.  
  526.    *Information can be lost during output.* The output formats
  527. supported by BFD do not provide identical facilities, and information
  528. which can be described in one form has nowhere to go in another format.
  529. One example of this is alignment information in `b.out'. There is
  530. nowhere in an `a.out' format file to store alignment information on the
  531. contained data, so when a file is linked from `b.out' and an `a.out'
  532. image is produced, alignment information will not propagate to the
  533. output file. (The linker will still use the alignment information
  534. internally, so the link is performed correctly).
  535.  
  536.    Another example is COFF section names. COFF files may contain an
  537. unlimited number of sections, each one with a textual section name. If
  538. the target of the link is a format which does not have many sections
  539. (e.g., `a.out') or has sections without names (e.g., the Oasys format),
  540. the link cannot be done simply. You can circumvent this problem by
  541. describing the desired input-to-output section mapping with the linker
  542. command language.
  543.  
  544.    *Information can be lost during canonicalization.* The BFD internal
  545. canonical form of the external formats is not exhaustive; there are
  546. structures in input formats for which there is no direct representation
  547. internally.  This means that the BFD back ends cannot maintain all
  548. possible data richness through the transformation between external to
  549. internal and back to external formats.
  550.  
  551.    This limitation is only a problem when an application reads one
  552. format and writes another.  Each BFD back end is responsible for
  553. maintaining as much data as possible, and the internal BFD canonical
  554. form has structures which are opaque to the BFD core, and exported only
  555. to the back ends. When a file is read in one format, the canonical form
  556. is generated for BFD and the application. At the same time, the back
  557. end saves away any information which may otherwise be lost. If the data
  558. is then written back in the same format, the back end routine will be
  559. able to use the canonical form provided by the BFD core as well as the
  560. information it prepared earlier.  Since there is a great deal of
  561. commonality between back ends, there is no information lost when
  562. linking or copying big endian COFF to little endian COFF, or `a.out' to
  563. `b.out'.  When a mixture of formats is linked, the information is only
  564. lost from the files whose format differs from the destination.
  565.  
  566. 
  567. File: ld.info,  Node: Canonical format,  Prev: BFD information loss,  Up: BFD outline
  568.  
  569. The BFD canonical object-file format
  570. ------------------------------------
  571.  
  572.    The greatest potential for loss of information occurs when there is
  573. the least overlap between the information provided by the source
  574. format, that stored by the canonical format, and that needed by the
  575. destination format. A brief description of the canonical form may help
  576. you understand which kinds of data you can count on preserving across
  577. conversions.
  578.  
  579. *files*
  580.      Information stored on a per-file basis includes target machine
  581.      architecture, particular implementation format type, a demand
  582.      pageable bit, and a write protected bit.  Information like Unix
  583.      magic numbers is not stored here--only the magic numbers' meaning,
  584.      so a `ZMAGIC' file would have both the demand pageable bit and the
  585.      write protected text bit set.  The byte order of the target is
  586.      stored on a per-file basis, so that big- and little-endian object
  587.      files may be used with one another.
  588.  
  589. *sections*
  590.      Each section in the input file contains the name of the section,
  591.      the section's original address in the object file, size and
  592.      alignment information, various flags, and pointers into other BFD
  593.      data structures.
  594.  
  595. *symbols*
  596.      Each symbol contains a pointer to the information for the object
  597.      file which originally defined it, its name, its value, and various
  598.      flag bits.  When a BFD back end reads in a symbol table, it
  599.      relocates all symbols to make them relative to the base of the
  600.      section where they were defined.  Doing this ensures that each
  601.      symbol points to its containing section.  Each symbol also has a
  602.      varying amount of hidden private data for the BFD back end.  Since
  603.      the symbol points to the original file, the private data format
  604.      for that symbol is accessible.  `ld' can operate on a collection
  605.      of symbols of wildly different formats without problems.
  606.  
  607.      Normal global and simple local symbols are maintained on output,
  608.      so an output file (no matter its format) will retain symbols
  609.      pointing to functions and to global, static, and common variables.
  610.      Some symbol information is not worth retaining; in `a.out', type
  611.      information is stored in the symbol table as long symbol names.
  612.      This information would be useless to most COFF debuggers; the
  613.      linker has command line switches to allow users to throw it away.
  614.  
  615.      There is one word of type information within the symbol, so if the
  616.      format supports symbol type information within symbols (for
  617.      example, COFF, IEEE, Oasys) and the type is simple enough to fit
  618.      within one word (nearly everything but aggregates), the
  619.      information will be preserved.
  620.  
  621. *relocation level*
  622.      Each canonical BFD relocation record contains a pointer to the
  623.      symbol to relocate to, the offset of the data to relocate, the
  624.      section the data is in, and a pointer to a relocation type
  625.      descriptor. Relocation is performed by passing messages through
  626.      the relocation type descriptor and the symbol pointer. Therefore,
  627.      relocations can be performed on output data using a relocation
  628.      method that is only available in one of the input formats. For
  629.      instance, Oasys provides a byte relocation format.  A relocation
  630.      record requesting this relocation type would point indirectly to a
  631.      routine to perform this, so the relocation may be performed on a
  632.      byte being written to a 68k COFF file, even though 68k COFF has no
  633.      such relocation type.
  634.  
  635. *line numbers*
  636.      Object formats can contain, for debugging purposes, some form of
  637.      mapping between symbols, source line numbers, and addresses in the
  638.      output file.  These addresses have to be relocated along with the
  639.      symbol information.  Each symbol with an associated list of line
  640.      number records points to the first record of the list.  The head
  641.      of a line number list consists of a pointer to the symbol, which
  642.      allows finding out the address of the function whose line number
  643.      is being described. The rest of the list is made up of pairs:
  644.      offsets into the section and line numbers. Any format which can
  645.      simply derive this information can pass it successfully between
  646.      formats (COFF, IEEE and Oasys).
  647.  
  648. 
  649. File: ld.info,  Node: MRI,  Next: Index,  Prev: BFD,  Up: Top
  650.  
  651. MRI Compatible Script Files
  652. ***************************
  653.  
  654.    To aid users making the transition to GNU `ld' from the MRI linker,
  655. `ld' can use MRI compatible linker scripts as an alternative to the
  656. more general-purpose linker scripting language described in *Note
  657. Command Language: Commands.  MRI compatible linker scripts have a much
  658. simpler command set than the scripting language otherwise used with
  659. `ld'.  GNU `ld' supports the most commonly used MRI linker commands;
  660. these commands are described here.
  661.  
  662.    In general, MRI scripts aren't of much use with the `a.out' object
  663. file format, since it only has three sections and MRI scripts lack some
  664. features to make use of them.
  665.  
  666.    You can specify a file containing an MRI-compatible script using the
  667. `-c' command-line option.
  668.  
  669.    Each command in an MRI-compatible script occupies its own line; each
  670. command line starts with the keyword that identifies the command (though
  671. blank lines are also allowed for punctuation).  If a line of an
  672. MRI-compatible script begins with an unrecognized keyword, `ld' issues
  673. a warning message, but continues processing the script.
  674.  
  675.    Lines beginning with `*' are comments.
  676.  
  677.    You can write these commands using all upper-case letters, or all
  678. lower case; for example, `chip' is the same as `CHIP'.  The following
  679. list shows only the upper-case form of each command.
  680.  
  681. `ABSOLUTE SECNAME'
  682. `ABSOLUTE SECNAME, SECNAME, ... SECNAME'
  683.      Normally, `ld' includes in the output file all sections from all
  684.      the input files.  However, in an MRI-compatible script, you can
  685.      use the `ABSOLUTE' command to restrict the sections that will be
  686.      present in your output program.  If the `ABSOLUTE' command is used
  687.      at all in a script, then only the sections named explicitly in
  688.      `ABSOLUTE' commands will appear in the linker output.  You can
  689.      still use other input sections (whatever you select on the command
  690.      line, or using `LOAD') to resolve addresses in the output file.
  691.  
  692. `ALIAS OUT-SECNAME, IN-SECNAME'
  693.      Use this command to place the data from input section IN-SECNAME
  694.      in a section called OUT-SECNAME in the linker output file.
  695.  
  696.      IN-SECNAME may be an integer.
  697.  
  698. `BASE EXPRESSION'
  699.      Use the value of EXPRESSION as the lowest address (other than
  700.      absolute addresses) in the output file.
  701.  
  702. `CHIP EXPRESSION'
  703. `CHIP EXPRESSION, EXPRESSION'
  704.      This command does nothing; it is accepted only for compatibility.
  705.  
  706. `END'
  707.      This command does nothing whatever; it's only accepted for
  708.      compatibility.
  709.  
  710. `FORMAT OUTPUT-FORMAT'
  711.      Similar to the `OUTPUT_FORMAT' command in the more general linker
  712.      language, but restricted to one of these output formats:
  713.  
  714.        1. S-records, if OUTPUT-FORMAT is `S'
  715.  
  716.        2. IEEE, if OUTPUT-FORMAT is `IEEE'
  717.  
  718.        3. COFF (the `coff-m68k' variant in BFD), if OUTPUT-FORMAT is
  719.           `COFF'
  720.  
  721. `LIST ANYTHING...'
  722.      Print (to the standard output file) a link map, as produced by the
  723.      `ld' command-line option `-M'.
  724.  
  725.      The keyword `LIST' may be followed by anything on the same line,
  726.      with no change in its effect.
  727.  
  728. `LOAD FILENAME'
  729. `LOAD FILENAME, FILENAME, ... FILENAME'
  730.      Include one or more object file FILENAME in the link; this has the
  731.      same effect as specifying FILENAME directly on the `ld' command
  732.      line.
  733.  
  734. `NAME OUTPUT-NAME'
  735.      OUTPUT-NAME is the name for the program produced by `ld'; the
  736.      MRI-compatible command `NAME' is equivalent to the command-line
  737.      option `-o' or the general script language command `OUTPUT'.
  738.  
  739. `ORDER SECNAME, SECNAME, ... SECNAME'
  740. `ORDER SECNAME SECNAME SECNAME'
  741.      Normally, `ld' orders the sections in its output file in the order
  742.      in which they first appear in the input files.  In an
  743.      MRI-compatible script, you can override this ordering with the
  744.      `ORDER' command.  The sections you list with `ORDER' will appear
  745.      first in your output file, in the order specified.
  746.  
  747. `PUBLIC NAME=EXPRESSION'
  748. `PUBLIC NAME,EXPRESSION'
  749. `PUBLIC NAME EXPRESSION'
  750.      Supply a value (EXPRESSION) for external symbol NAME used in the
  751.      linker input files.
  752.  
  753. `SECT SECNAME, EXPRESSION'
  754. `SECT SECNAME=EXPRESSION'
  755. `SECT SECNAME EXPRESSION'
  756.      You can use any of these three forms of the `SECT' command to
  757.      specify the start address (EXPRESSION) for section SECNAME.  If
  758.      you have more than one `SECT' statement for the same SECNAME, only
  759.      the *first* sets the start address.
  760.  
  761. 
  762. File: ld.info,  Node: Index,  Prev: MRI,  Up: Top
  763.  
  764. Index
  765. *****
  766.  
  767. * Menu:
  768.  
  769. * ":                                    Symbols.
  770. * *( COMMON ):                          Section Placement.
  771. * *(SECTION):                           Section Placement.
  772. * -(:                                   Options.
  773. * -verbose:                             Options.
  774. * -AARCH:                               Options.
  775. * -b FORMAT:                            Options.
  776. * -Bstatic:                             Options.
  777. * -c MRI-CMDFILE:                       Options.
  778. * -d:                                   Options.
  779. * -dc:                                  Options.
  780. * -defsym SYMBOL=EXP:                   Options.
  781. * -dp:                                  Options.
  782. * -dynamic-linker FILE:                 Options.
  783. * -e ENTRY:                             Options.
  784. * -F:                                   Options.
  785. * -format:                              Options.
  786. * -G:                                   Options.
  787. * -g:                                   Options.
  788. * -help:                                Options.
  789. * -i:                                   Options.
  790. * -lARCHIVE:                            Options.
  791. * -LDIR:                                Options.
  792. * -M:                                   Options.
  793. * -m EMULATION:                         Options.
  794. * -Map:                                 Options.
  795. * -n:                                   Options.
  796. * -N:                                   Options.
  797. * -noinhibit-exec:                      Options.
  798. * -o OUTPUT:                            Options.
  799. * -oformat:                             Options.
  800. * -r:                                   Options.
  801. * -R FILE:                              Options.
  802. * -relax:                               Options.
  803. * -rpath:                               Options.
  804. * -S:                                   Options.
  805. * -s:                                   Options.
  806. * -soname:                              Options.
  807. * -t:                                   Options.
  808. * -T SCRIPT:                            Options.
  809. * -Tbss ORG:                            Options.
  810. * -Tdata ORG:                           Options.
  811. * -traditional-format:                  Options.
  812. * -Ttext ORG:                           Options.
  813. * -u SYMBOL:                            Options.
  814. * -Ur:                                  Options.
  815. * -v:                                   Options.
  816. * -V:                                   Options.
  817. * -version:                             Options.
  818. * -warn-comon:                          Options.
  819. * -warn-once:                           Options.
  820. * -X:                                   Options.
  821. * -x:                                   Options.
  822. * -y SYMBOL:                            Options.
  823. * .:                                    Location Counter.
  824. * 0x:                                   Integers.
  825. * ;:                                    Assignment.
  826. * =FILL:                                Section Options.
  827. * >REGION:                              Section Options.
  828. * -relax on i960:                       i960.
  829. * ABSOLUTE (MRI):                       MRI.
  830. * ALIAS (MRI):                          MRI.
  831. * BASE (MRI):                           MRI.
  832. * CHIP (MRI):                           MRI.
  833. * END (MRI):                            MRI.
  834. * FORMAT (MRI):                         MRI.
  835. * LIST (MRI):                           MRI.
  836. * LOAD (MRI):                           MRI.
  837. * NAME (MRI):                           MRI.
  838. * ORDER (MRI):                          MRI.
  839. * PUBLIC (MRI):                         MRI.
  840. * SECT (MRI):                           MRI.
  841. * [SECTION...], not supported:          Section Placement.
  842. * FILENAME:                             Section Placement.
  843. * FILENAME(SECTION):                    Section Placement.
  844. * SYMBOL = EXPRESSION ;:                Section Data Expressions.
  845. * SYMBOL F= EXPRESSION ;:               Section Data Expressions.
  846. * absolute and relocatable symbols:     Assignment.
  847. * ABSOLUTE(EXP):                        Arithmetic Functions.
  848. * ADDR(SECTION):                        Arithmetic Functions.
  849. * ALIGN(EXP):                           Arithmetic Functions.
  850. * aligning sections:                    Section Options.
  851. * allocating memory:                    MEMORY.
  852. * architectures:                        Options.
  853. * archive files, from cmd line:         Options.
  854. * arithmetic:                           Expressions.
  855. * arithmetic operators:                 Operators.
  856. * assignment in scripts:                Assignment.
  857. * assignment, in section defn:          Section Data Expressions.
  858. * AT ( LDADR ):                         Section Options.
  859. * back end:                             BFD.
  860. * BFD canonical format:                 Canonical format.
  861. * BFD requirements:                     BFD.
  862. * binary input files:                   Option Commands.
  863. * binary input format:                  Options.
  864. * BLOCK(ALIGN):                         Section Options.
  865. * BYTE(EXPRESSION):                     Section Data Expressions.
  866. * C++ constructors, arranging in link:  Option Commands.
  867. * combining symbols, warnings on:       Options.
  868. * command files:                        Commands.
  869. * command line:                         Options.
  870. * commands, fundamental:                Scripts.
  871. * comments:                             Scripts.
  872. * common allocation:                    Option Commands.
  873. * common allocation:                    Options.
  874. * commons in output:                    Section Placement.
  875. * compatibility, MRI:                   Options.
  876. * constructors:                         Options.
  877. * CONSTRUCTORS:                         Option Commands.
  878. * constructors, arranging in link:      Option Commands.
  879. * contents of a section:                Section Placement.
  880. * CREATE_OBJECT_SYMBOLS:                Section Data Expressions.
  881. * current output location:              Location Counter.
  882. * dbx:                                  Options.
  883. * decimal integers:                     Integers.
  884. * default input format:                 Environment.
  885. * DEFINED(SYMBOL):                      Arithmetic Functions.
  886. * deleting local symbols:               Options.
  887. * direct output:                        Section Data Expressions.
  888. * discontinuous memory:                 MEMORY.
  889. * dot:                                  Location Counter.
  890. * dynamic linker, from command line:    Options.
  891. * emulation:                            Options.
  892. * entry point, defaults:                Entry Point.
  893. * entry point, from command line:       Options.
  894. * ENTRY(SYMBOL):                        Entry Point.
  895. * expression evaluation order:          Evaluation.
  896. * expression syntax:                    Expressions.
  897. * expression, absolute:                 Arithmetic Functions.
  898. * expressions in a section:             Section Data Expressions.
  899. * filename symbols:                     Section Data Expressions.
  900. * files and sections, section defn:     Section Placement.
  901. * files, including in output sections:  Section Placement.
  902. * fill pattern, entire section:         Section Options.
  903. * FILL(EXPRESSION):                     Section Data Expressions.
  904. * first input file:                     Option Commands.
  905. * first instruction:                    Entry Point.
  906. * FLOAT:                                Option Commands.
  907. * FORCE_COMMON_ALLOCATION:              Option Commands.
  908. * format, output file:                  Option Commands.
  909. * functions in expression language:     Arithmetic Functions.
  910. * fundamental script commands:          Scripts.
  911. * GNU linker:                           Overview.
  912. * GNUTARGET:                            Option Commands.
  913. * GNUTARGET:                            Environment.
  914. * GROUP ( FILES ):                      Option Commands.
  915. * grouping input files:                 Option Commands.
  916. * groups of archives:                   Options.
  917. * H8/300 support:                       H8/300.
  918. * header size:                          Arithmetic Functions.
  919. * help:                                 Options.
  920. * hexadecimal integers:                 Integers.
  921. * holes:                                Location Counter.
  922. * holes, filling:                       Section Data Expressions.
  923. * i960 support:                         i960.
  924. * incremental link:                     Options.
  925. * INPUT ( FILES ):                      Option Commands.
  926. * input file format:                    Option Commands.
  927. * input filename symbols:               Section Data Expressions.
  928. * input files, displaying:              Options.
  929. * input files, section defn:            Section Placement.
  930. * input format:                         Options.
  931. * input format:                         Options.
  932. * input sections to output section:     Section Placement.
  933. * integer notation:                     Integers.
  934. * integer suffixes:                     Integers.
  935. * internal object-file format:          Canonical format.
  936. * K and M integer suffixes:             Integers.
  937. * l =:                                  MEMORY.
  938. * L, deleting symbols beginning:        Options.
  939. * layout of output file:                Scripts.
  940. * lazy evaluation:                      Evaluation.
  941. * len =:                                MEMORY.
  942. * LENGTH =:                             MEMORY.
  943. * link map:                             Options.
  944. * link map:                             Options.
  945. * load address, specifying:             Section Options.
  946. * loading, preventing:                  Section Options.
  947. * local symbols, deleting:              Options.
  948. * location counter:                     Location Counter.
  949. * LONG(EXPRESSION):                     Section Data Expressions.
  950. * M and K integer suffixes:             Integers.
  951. * machine architecture, output:         Option Commands.
  952. * machine dependencies:                 Machine Dependent.
  953. * MEMORY:                               MEMORY.
  954. * memory region attributes:             MEMORY.
  955. * memory regions and sections:          Section Options.
  956. * MRI compatibility:                    MRI.
  957. * names:                                Symbols.
  958. * naming memory regions:                MEMORY.
  959. * naming output sections:               Section Definition.
  960. * naming the output file:               Option Commands.
  961. * naming the output file:               Options.
  962. * negative integers:                    Integers.
  963. * NEXT(EXP):                            Arithmetic Functions.
  964. * NMAGIC:                               Options.
  965. * NOFLOAT:                              Option Commands.
  966. * NOLOAD:                               Section Options.
  967. * Non constant expression:              Assignment.
  968. * o =:                                  MEMORY.
  969. * objdump -i:                           BFD.
  970. * object file management:               BFD.
  971. * object files:                         Options.
  972. * object formats available:             BFD.
  973. * object size:                          Options.
  974. * octal integers:                       Integers.
  975. * OMAGIC:                               Options.
  976. * opening object files:                 BFD outline.
  977. * Operators for arithmetic:             Operators.
  978. * options:                              Options.
  979. * org =:                                MEMORY.
  980. * ORIGIN =:                             MEMORY.
  981. * OUTPUT ( FILENAME ):                  Option Commands.
  982. * output file after errors:             Options.
  983. * output file layout:                   Scripts.
  984. * OUTPUT_ARCH ( BFDNAME ):              Option Commands.
  985. * OUTPUT_FORMAT ( BFDNAME ):            Option Commands.
  986. * partial link:                         Options.
  987. * path for libraries:                   Option Commands.
  988. * precedence in expressions:            Operators.
  989. * prevent unnecessary loading:          Section Options.
  990. * provide:                              Assignment.
  991. * QUAD(EXPRESSION):                     Section Data Expressions.
  992. * quoted symbol names:                  Symbols.
  993. * read-only text:                       Options.
  994. * read/write from cmd line:             Options.
  995. * regions of memory:                    MEMORY.
  996. * relaxing addressing modes:            Options.
  997. * relaxing on H8/300:                   H8/300.
  998. * relaxing on i960:                     i960.
  999. * relocatable and absolute symbols:     Assignment.
  1000. * relocatable output:                   Options.
  1001. * requirements for BFD:                 BFD.
  1002. * retaining specified symbols:          Options.
  1003. * rounding up location counter:         Arithmetic Functions.
  1004. * runtime library name:                 Options.
  1005. * runtime library search path:          Options.
  1006. * scaled integers:                      Integers.
  1007. * script files:                         Options.
  1008. * search directory, from cmd line:      Options.
  1009. * search path, libraries:               Option Commands.
  1010. * SEARCH_DIR ( PATH ):                  Option Commands.
  1011. * section address:                      Arithmetic Functions.
  1012. * section address:                      Section Options.
  1013. * section alignment:                    Section Options.
  1014. * section definition:                   Section Definition.
  1015. * section defn, full syntax:            Section Options.
  1016. * section fill pattern:                 Section Options.
  1017. * section size:                         Arithmetic Functions.
  1018. * section start:                        Section Options.
  1019. * section, assigning to memory region:  Section Options.
  1020. * SECTIONS:                             SECTIONS.
  1021. * segment origins, cmd line:            Options.
  1022. * semicolon:                            Assignment.
  1023. * SHORT(EXPRESSION):                    Section Data Expressions.
  1024. * SIZEOF(SECTION):                      Arithmetic Functions.
  1025. * sizeof_headers:                       Arithmetic Functions.
  1026. * SIZEOF_HEADERS:                       Arithmetic Functions.
  1027. * specify load address:                 Section Options.
  1028. * standard Unix system:                 Options.
  1029. * start address, section:               Section Options.
  1030. * start of execution:                   Entry Point.
  1031. * STARTUP ( FILENAME ):                 Option Commands.
  1032. * strip all symbols:                    Options.
  1033. * strip debugger symbols:               Options.
  1034. * stripping all but some symbols:       Options.
  1035. * suffixes for integers:                Integers.
  1036. * symbol defaults:                      Arithmetic Functions.
  1037. * symbol definition, scripts:           Assignment.
  1038. * symbol names:                         Symbols.
  1039. * symbol tracing:                       Options.
  1040. * symbol-only input:                    Options.
  1041. * symbols, from command line:           Options.
  1042. * symbols, relocatable and absolute:    Assignment.
  1043. * symbols, retaining selectively:       Options.
  1044. * synthesizing linker:                  Options.
  1045. * synthesizing on H8/300:               H8/300.
  1046. * TARGET ( FORMAT ):                    Option Commands.
  1047. * traditional format:                   Options.
  1048. * unallocated address, next:            Arithmetic Functions.
  1049. * undefined symbol:                     Options.
  1050. * undefined symbols, warnings on:       Options.
  1051. * uninitialized data:                   Section Placement.
  1052. * unspecified memory:                   Section Data Expressions.
  1053. * usage:                                Options.
  1054. * variables, defining:                  Assignment.
  1055. * verbose:                              Options.
  1056. * version:                              Options.
  1057. * version:                              Options.
  1058. * warnings, on combining symbols:       Options.
  1059. * warnings, on undefined symbols:       Options.
  1060. * what is this?:                        Overview.
  1061.  
  1062.  
  1063.